package com.tn.threadpool;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName HeartbeatThreadPool
 * @Description TODO
 * @Author Yezhongzhu
 * @Date 2022/1/4 10:56
 * @Version v1.0
 **/
@Configuration
public class HeartbeatThreadPool {
    @Bean
    public ThreadPoolExecutor getPool(){
        return new ThreadPoolExecutor(
                3,
                8,
                30,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<Runnable>(10),
                new org.apache.tomcat.util.threads.ThreadPoolExecutor.DiscardOldestPolicy()
        );
    }
}
